package com.yonyou.pmclouds.stagecheck.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.inspectitem.entity.InspectItemVO;
import com.yonyou.pmclouds.inspectitem.rmiitf.InspectItemService;
import com.yonyou.pmclouds.stagecheck.entity.StageCheckVO;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author chulf
 * @date 2020/4/1
 */
@Component
public class StageCheckAfterUpdateFillInspectItemInfoProcess implements SingleProcessor<StageCheckVO>{
    @Autowired
    private InspectItemService itemService;
    @Override
    public void process(StageCheckVO vo, StageCheckVO orig) throws BusinessException {
        InspectItemVO[] itemVOs = vo.getInspectItemVOS();
        if(ArrayUtils.isEmpty(itemVOs)) {
            return;
        }
        String pkComprehensiveAcceptance = vo.getPkStageCheck();
        for (InspectItemVO inspectItemVO : itemVOs) {
            inspectItemVO.setPk_bill(pkComprehensiveAcceptance);
            inspectItemVO.setPk_project(vo.getPkProject());
        }
        // 修改检查项
        itemService.update(itemVOs, vo);
    }

}